#include "Object.hpp"
#include <iostream>
#include <cmath>
#include <cstring>

Object::Object(char* new_label, double new_x, double new_y, double new_vx, double new_vy, double new_m) {
    pos.x = new_x;
    pos.y = new_y;
    vel.x = new_vx;
    vel.y = new_vy;
    m = new_m;
    setLabel(new_label);
    is_star = false;
}

Object::Object(char* new_label, Vec2d new_pos, Vec2d new_vel, double new_m) {
    pos = new_pos;
    vel = new_vel;
    m = new_m;
    setLabel(new_label);
    is_star = false;
}

Object::Object(char* new_label, bool new_is_star, double new_x, double new_y, double new_vx, double new_vy, double new_m) {
    pos.x = new_x;
    pos.y = new_y;
    vel.x = new_vx;
    vel.y = new_vy;
    m = new_m;
    setLabel(new_label);
    is_star = new_is_star;
}

Object::Object() {
    pos = vel = Vec2d(0,0);
    m = 20; // nechceme nehmotne hmotne body ze
    label[0] = '\0';
    is_star = false;
}

double Object::distanceTo(Object obj2) {
    return (obj2.getPos() - this->getPos()).length();
}

void Object::writeOut() {
    std::cout << label << ":  x=" << pos.x << " y=" << pos.y << " m=" << m << " v=" << vel.length() << std::endl;
}

void Object::setLabel(char* new_label) {
    std::strcpy(label, new_label);
}
